// Log Manager
// (c) jimon game studio

#ifndef JEH_ILOGMANAGER
#define JEH_ILOGMANAGER

#include "Config_Engine.h"
#include "jeTypes.h"
#include "jeSingleton.h"
#include "jeUnknown.h"
#include "jeStl.h"

namespace je
{
	namespace core
	{
		//! Log Manager interface
		class ILogManager:public je::jeUnknown
		{
		public:
			//! Destructor
			virtual ~ILogManager()
			{
			}

			//! Log message levels
			enum LogMessageLevels
			{
				LML_NULL = 0,

				LML_LOG_DETAILS,
				LML_LOG,
				LML_WARNING,
				LML_ERROR,

				LML_MAX
			};

			//! Add String to log
			//! for log we can use only ascii, no unicode
			virtual void AddLog(const jeStringc & Log,LogMessageLevels WarningLevel) = 0;

			//! Log Callback Type
			typedef void (*jeLogFunction)(const jeStringc & Log,LogMessageLevels WarningLevel);

			//! Set Log Callback
			virtual void SetLogCallback(const jeLogFunction & Callback) = 0;
		};

		DECLARE_SINGLETON_E(JE_ENGINE_FUNCTION_API,JE_ENGINE_FUNCTION_CALL,LogManager)
	}
}

#ifdef JE_LOG_MACRO
	#define JELOG_BASE(msg,detail) je::core::GetLogManager()->AddLog(je::jeStringc(msg)+je::jeStringc(" (")+je::jeStringc(__FILE__)+je::jeStringc(":")+je::jeStringc(__LINE__)+je::jeStringc(")"),je::core::ILogManager::detail);
	#define JELOG_BASE_SHORT(msg,detail) je::core::GetLogManager()->AddLog(je::jeStringc(msg),je::core::ILogManager::detail);
	#ifdef JE_DEBUG
		#define JELOG_D(msg) JELOG_BASE_SHORT(msg,LML_LOG_DETAILS)
		#define JELOG(msg) JELOG_BASE_SHORT(msg,LML_LOG)
		#define JELOG_SHORT(msg) JELOG_BASE_SHORT(msg,LML_LOG)
		#define JELOG_W(msg) JELOG_BASE(msg,LML_WARNING)
		#define JELOG_E(msg) JELOG_BASE(msg,LML_ERROR)
	#else
		#define JELOG_D(msg) JELOG_BASE_SHORT(msg,LML_LOG_DETAILS)
		#define JELOG(msg) JELOG_BASE_SHORT(msg,LML_LOG)
		#define JELOG_SHORT(msg) JELOG_BASE_SHORT(msg,LML_LOG)
		#define JELOG_W(msg) JELOG_BASE(msg,LML_WARNING)
		#define JELOG_E(msg) JELOG_BASE(msg,LML_ERROR)
	#endif
#else
	#define JELOG_D(msg) {}
	#define JELOG(msg) {}
	#define JELOG_SHORT(msg) {}
	#define JELOG_W(msg) {}
	#define JELOG_E(msg) {}
#endif


#endif
